import java.util.TreeSet;

public class Student implements Comparable<Student> {
    private String lastName = "";
    private String firstName = "";
    private int studentID = 0;
    private int numCourses = 0;

    public Student(String lastName, String firstName, int studentID,
		   int numCourses) {
	this.lastName = lastName;
	this.firstName = firstName;
	this.studentID = studentID;
	this.numCourses = numCourses;
    }
    
    public boolean equals(Object o) {
	if (!(o instanceof Student)) {
	    return false;
	} else {
	    Student that = (Student)o;
	    
	    return lastName.equals(that.lastName) &&
		firstName.equals(that.firstName) &&
		studentID == that.studentID &&
		numCourses == that.numCourses;
	}
    }

    public int compareTo(Student that) {
	int compare;

	compare = lastName.compareTo(that.lastName);
	if (compare != 0) return compare;
	compare = firstName.compareTo(that.firstName);
	if (compare != 0) return compare;
	compare = studentID - that.studentID;
	if (compare != 0) return compare;
	compare = numCourses - that.numCourses;
	return compare;
    }

    public String toString() {
	return "Student["+lastName+", "+firstName+", "+
	    studentID+", "+numCourses+"]";
    }

    public static void main(String[] args) {
	TreeSet<Student> set = new TreeSet<Student>();

	set.add(new Student("Thoreau", "Henry", 1, 0));
	set.add(new Student("Siegel", "Stephen", 12345, 5));
	set.add(new Student("Beethoven", "L. van", 5, 2));

	for (Student s : set) {
	    System.out.println(s);
	}
	System.out.flush();
    }
}